<!--
 * @Description:
 * @Author: zhaolei
 * @Date: 2023-04-13 12:24:10
-->
<template>
  <el-dialog
    title="被举报内容详情"
    :visible.sync="visible"
    width="60%"
    append-to-body
  >
    <avue-form
      ref="addForm"
      v-model="form"
      :option="tableOption"
    >
    </avue-form>
  </el-dialog>
</template>

<script>
import { mapGetters } from 'vuex';
import { tableOption } from '@/const/crud/content/report-record';
// import { BROADCAST_TYPE } from '@/const/type';
import { getObj } from '@/api/core/reportManage';
export default {
  name: 'reportRecordPopup',
  props: {
    id: {
      type: [Object, String],
    },
    value: {
      type: Boolean,
      default: false,
    },
    isComment: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      form: {},
      loading: false,
    };
  },
  computed: {
    visible: {
      get() {
        return this.value;
      },
      set(val) {
        this.$emit('input', val);
      },
    },
    ...mapGetters(['userInfo', 'access_token']),
    tableOption() {
      return tableOption(this.isComment);
    },
  },
  watch: {
    visible(val) {
      if (val) {
        this.$nextTick(() => {
          this.id && this.getDetail();
        });
      } else {
        this.$refs.addForm && this.$refs.addForm.resetForm();
      }
    },
  },
  methods: {
    async getDetail() {
      const res = await getObj(this.id);
      if (res.data.data) {
        this.form = { ...res.data.data };
        const temp = JSON.parse(this.form.files);
        this.form.petPicture = temp.map((item) => {
          let type = 'mov';
          if (item.type === 'image') {
            type = 'jpg';
          }
          return `${item.url}?.${type}`;
        });
      }
    },
  },
};
</script>

<style lang='scss' scoped>
</style>
